package com.tw;

import java.util.*;
public class StudentSystem {
    private List<Student> studentList=new ArrayList<>();
    private Scanner scanner=new Scanner(System.in);
    public StudentSystem(){
    }
    public StudentSystem(List<Student> studentList) {
        this.studentList = studentList;
    }
    public List<Student> getStudentList() {
        return studentList;
    }
    public void setStudentList(List<Student> studentList) {
        this.studentList = studentList;
    }
    public void addStudent(){
        System.out.println("请输入学号：");
        int id = scanner.nextInt();
        System.out.println("请输入姓名：");
        String name = scanner.next();
        System.out.println("请输入语文成绩：");
        int  chinese= scanner.nextInt();
        System.out.println("请输入数学成绩：");
        int mathematics = scanner.nextInt();
        System.out.println("请输入外语成绩：");
        int English = scanner.nextInt();
        System.out.println("请输入总成绩：");
        int TotalScore = scanner.nextInt();
        Student st =new Student(id,name,chinese,mathematics,English,TotalScore);
        studentList.add(st);
        System.out.println("创建成功");
    }
    public List<Student> findAll(){
        return studentList;
    }
    public void mangeStudent(){
        while (true){
            System.out.println("1.添加学生 ");
            System.out.println("2.生成成绩单 ");
            System.out.println("3.退出");
            System.out.println("请输入你的选择（1～3）：");
            Scanner sc=new Scanner(System.in);
            int optNum=sc.nextInt();
            switch (optNum){
                case 1:
                    System.out.println("添加学生");
                    this.addStudent();
                    break;
                case 2:
                    System.out.println("打印成绩");
                    List<Student> studentList=this.findAll();
                    System.out.println("学号     姓名     语文     数学     英语     总分");
                    if(studentList.size()<=0){
                        System.out.println("         ");
                    }else {
                        for(Student st :studentList){
                            st.show();
                        }
                    }
                    break;
                default:
                    System.out.println("退出系统");
                    return;
            }
        }
    }
}
